<?php

    class PagerNavigation
    {
        const NUM_PAGES_VISIBLE = 4;

        public static function Generate( Pager $pager, $templatePath, $url = '' )
        {
            $navigation = '';

            if ( $pager->GetNumResults() > 0 )
            {
                $tmplDir  = dirname($templatePath);
                $tmplFile = basename($templatePath);

                $showArrows = self::NUM_PAGES_VISIBLE < $pager->GetLastPage();

                $tmpl = Core::CreateTemplateEngine( $tmplDir );
                $tmpl->clearVars();
                $tmpl->define( 'pagerNav', $tmplFile );
                $tmpl->set( 'showArrows', $showArrows );
                $tmpl->set( 'url', $url );
                $tmpl->setArr( 'pager', $pager );
                $tmpl->setArr( 'pages', $pager->GetPages(self::NUM_PAGES_VISIBLE) );
                $tmpl->parse( 'content', 'pagerNav' );
                $navigation = $tmpl->getGenerated();
            }

            return $navigation;
        }
    }
?>